package com.example.perplonews.a_b_utils

import android.app.Application
import android.database.sqlite.SQLiteDatabase
import com.example.perplonews.a_b_entity.greendao.DaoMaster
import com.example.perplonews.a_b_entity.greendao.DaoSession
//import com.tencent.rtmp.TXLiveBase


class App : Application(){
    companion object {
        private var mSession: DaoSession? = null

        // 供外接使用
        fun getDaoSession(): DaoSession? {
            return App.mSession
        }
    }

    override fun onCreate() {
        super.onCreate()
        val licenceURL = "http://license.vod2.myqcloud.com/license/v1/8513274834e3bf47e6679d14d5e6efe4/TXLiveSDK.licence" // 获取到的 licence url

        val licenceKey = "51618691b5c9e540ebb419e20b1827bc" // 获取到的 licence key

//        TXLiveBase.getInstance().setLicence(this, licenceURL, licenceKey)
        initDb()
    }

    private fun initDb() {
//         1、获取需要连接的数据库
        val devOpenHelper = DaoMaster.DevOpenHelper(this, "paper.db")
        val db: SQLiteDatabase = devOpenHelper.getWritableDatabase()
        // 2、创建数据库连接
        val daoMaster = DaoMaster(db)
        // 3、创建数据库会话
        App.mSession = daoMaster.newSession()



    }

}